def happynum(n):
    for i in range(20):
        b=0
        while n!=0:
            a=n%10
            n=n//10
            b=b+a*a
        n=b
        if b==1:
            return True
    return False

print(happynum(int(input("Please enter a random number:"))))